imx: add i.MX8 SoCs build info SIP(silicon provider) service support
authorAnson Huang <[email protected]>
Fri, 18 Jan 2019 02:43:59 +0000 (10:43 +0800)
committerAnson Huang <[email protected]>
Fri, 18 Jan 2019 03:23:04 +0000 (11:23 +0800)
This patch adds NXP i.MX8 SoCs' build info SIP support for easy debug.
With this function enabled, TF-A's commit hash can be showed in u-boot
debug console when booting up, when there is any issue which could be
related to TF-A, users can use the commit hash value to easily identify
which commit introduces the issue.

Signed-off-by: Anson Huang <[email protected]>
plat/imx/common/imx_sip_handler.c
plat/imx/common/imx_sip_svc.c
plat/imx/common/include/imx_sip_svc.h

index 469e2953255662f9cab7b79d8c55cad3e918f2b7..55639cdf0edb4748f735cf1744602e0912549755 100644 (file)
@@ -7,6 +7,7 @@
 #include <stdlib.h>
 #include <stdint.h>
 #include <std_svc.h>
+#include <string.h>
 #include <platform_def.h>
 #include <common/debug.h>
 #include <common/runtime_svc.h>
@@ -137,3 +138,46 @@ int imx_misc_set_temp_handler(uint32_t smc_fid,
 {
        return sc_misc_set_temp(ipc_handle, x1, x2, x3, x4);
 }
+
+static uint64_t imx_get_commit_hash(u_register_t x2,
+                   u_register_t x3,
+                   u_register_t x4)
+{
+       /* Parse the version_string */
+       char *parse = (char *)version_string;
+       uint64_t hash = 0;
+
+       do {
+               parse = strchr(parse, '-');
+               if (parse) {
+                       parse += 1;
+                       if (*(parse) == 'g') {
+                               /* Default is 7 hexadecimal digits */
+                               memcpy((void *)&hash, (void *)(parse + 1), 7);
+                               break;
+                       }
+               }
+
+       } while (parse != NULL);
+
+       return hash;
+}
+
+uint64_t imx_buildinfo_handler(uint32_t smc_fid,
+                   u_register_t x1,
+                   u_register_t x2,
+                   u_register_t x3,
+                   u_register_t x4)
+{
+       uint64_t ret;
+
+       switch (x1) {
+       case IMX_SIP_BUILDINFO_GET_COMMITHASH:
+               ret = imx_get_commit_hash(x2, x3, x4);
+               break;
+       default:
+               return SMC_UNK;
+       }
+
+       return ret;
+}
index d66c24e09590b17fffec572d542b4560c754763f..c27fbf2e371dec5705221a53e057d90ad7f547cb 100644 (file)
@@ -40,6 +40,8 @@ static uintptr_t imx_sip_handler(unsigned int smc_fid,
        case IMX_SIP_MISC_SET_TEMP:
                SMC_RET1(handle, imx_misc_set_temp_handler(smc_fid, x1, x2, x3, x4));
 #endif
+       case  IMX_SIP_BUILDINFO:
+               SMC_RET1(handle, imx_buildinfo_handler(smc_fid, x1, x2, x3, x4));
        default:
                WARN("Unimplemented i.MX SiP Service Call: 0x%x\n", smc_fid);
                SMC_RET1(handle, SMC_UNK);
index c259d23ca6585672c83f639f05b0e57f31362041..648be3773cadffe00c465386ce37d7ea6ee9fedf 100644 (file)
@@ -14,6 +14,9 @@
 #define IMX_SIP_SRTC                   0xC2000002
 #define IMX_SIP_SRTC_SET_TIME          0x00
 
+#define IMX_SIP_BUILDINFO                      0xC2000003
+#define IMX_SIP_BUILDINFO_GET_COMMITHASH       0x00
+
 #define IMX_SIP_WAKEUP_SRC             0xC2000009
 #define IMX_SIP_WAKEUP_SRC_SCU         0x1
 #define IMX_SIP_WAKEUP_SRC_IRQSTEER    0x2
@@ -35,6 +38,9 @@ int imx_otp_handler(uint32_t smc_fid, void *handle,
 int imx_misc_set_temp_handler(uint32_t smc_fid, u_register_t x1,
                              u_register_t x2, u_register_t x3,
                              u_register_t x4);
+uint64_t imx_buildinfo_handler(uint32_t smc_fid, u_register_t x1,
+                              u_register_t x2, u_register_t x3,
+                              u_register_t x4);
 #endif
 
 #endif /* __IMX_SIP_SVC_H__ */